﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using YW.Common;
using LTP.Accounts.Bus;
namespace YW.Web.YWXT.YW_xfjlzb
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					Guid ywid=new Guid(Request.Params["id"]);
					ShowInfo(ywid);
				}
			}
		}
			
	private void ShowInfo(Guid ywid)
	{
		YW.BLL.YWXT.YW_xfjlzb bll=new YW.BLL.YWXT.YW_xfjlzb();
		YW.Model.YWXT.YW_xfjlzb model=bll.GetModel(ywid);
		this.lblywid.Text=model.ywid.ToString();
		this.lblzbid.Text=model.zbid.ToString();
		this.txtxfdh.Text=model.xfdh;
		this.txtxflx.Text=model.xflx;
		this.txtEMPI.Text=model.EMPI;
		this.txtksid.Text=model.ksid;
		this.txtysid.Text=model.ysid;
		this.txtyzid.Text=model.yzid;
		this.txtxfsj.Text=model.xfsj.ToString();
		this.txtkh.Text=model.kh;
		this.txtaddtime.Text=model.addtime.ToString();

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtxfdh.Text.Trim().Length==0)
			{
				strErr+="消费单号不能为空！\\n";	
			}
			if(this.txtxflx.Text.Trim().Length==0)
			{
				strErr+="消费类型不能为空！\\n";	
			}
			if(this.txtEMPI.Text.Trim().Length==0)
			{
				strErr+="EMPI不能为空！\\n";	
			}
			if(this.txtksid.Text.Trim().Length==0)
			{
				strErr+="科室ID不能为空！\\n";	
			}
			if(this.txtysid.Text.Trim().Length==0)
			{
				strErr+="医生ID不能为空！\\n";	
			}
			if(this.txtyzid.Text.Trim().Length==0)
			{
				strErr+="驿站ID不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtxfsj.Text))
			{
				strErr+="消费时间格式错误！\\n";	
			}
			if(this.txtkh.Text.Trim().Length==0)
			{
				strErr+="kh不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtaddtime.Text))
			{
				strErr+="addtime格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			Guid ywid= new Guid(this.lblywid.Text);
			Guid zbid= new Guid(this.lblzbid.Text);
			string xfdh=this.txtxfdh.Text;
			string xflx=this.txtxflx.Text;
			string EMPI=this.txtEMPI.Text;
			string ksid=this.txtksid.Text;
			string ysid=this.txtysid.Text;
			string yzid=this.txtyzid.Text;
			DateTime xfsj=DateTime.Parse(this.txtxfsj.Text);
			string kh=this.txtkh.Text;
			DateTime addtime=DateTime.Parse(this.txtaddtime.Text);


			YW.Model.YWXT.YW_xfjlzb model=new YW.Model.YWXT.YW_xfjlzb();
			model.ywid=ywid;
			model.zbid=zbid;
			model.xfdh=xfdh;
			model.xflx=xflx;
			model.EMPI=EMPI;
			model.ksid=ksid;
			model.ysid=ysid;
			model.yzid=yzid;
			model.xfsj=xfsj;
			model.kh=kh;
			model.addtime=addtime;

			YW.BLL.YWXT.YW_xfjlzb bll=new YW.BLL.YWXT.YW_xfjlzb();
			bll.Update(model);
			YW.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
